package com.topideal.supplychain.hades.util;

import java.util.Locale;
import org.springframework.context.MessageSource;
import com.topideal.supplychain.framework.common.SpringUtils;

public class MessageUtils {

    private static MessageSource messageSource;

    private final static Locale locale = Locale.CHINA;

    /**
     * 根据消息键和参数 获取消息 委托给spring messageSource
     *
     * @param code 消息键
     * @param args 参数
     * @return
     */
    public static String message(String code, Object... args) {
        if (messageSource == null) {
            messageSource = SpringUtils.getBean(MessageSource.class);
        }
        return messageSource.getMessage(code, args, MessageUtils.locale);
    }
}
